import 'dart:async';

import 'package:flutter/services.dart';

class MaterialRfidPlugin {
  static const MethodChannel _channel =
      const MethodChannel('material_rfid_plugin');

  static Future<String> get platformVersion async {
    final String version = await _channel.invokeMethod('getPlatformVersion');
    return version;
  }

  static Future<bool> get init async {
    final bool version = await _channel.invokeMethod('init');
    return version;
  }

  static Future<bool> get free async {
    final bool version = await _channel.invokeMethod('free');
    return version;
  }

  static Future<String> readData ({
    String accessPwd,
    String bank,
    int ptr,
    int cnt,
    String uii,
  }) async {
    return await _channel.invokeMethod(
      "readData",
      {
        "accessPwd": accessPwd,
        "bank": bank,
        "ptr": ptr,
        "cnt": cnt,
        "uii": uii,
      },
    );
  }

  static Future<List<String>> get readTagFromBuffer async {
    final List<String> tags = await _channel.invokeListMethod('readTag');
    return tags;
  }

  static Future<bool> startInventoryTag ({
    int flagAnti,
    int initQ,
  })  async {
    final bool b = await _channel.invokeMethod('startInventoryTag', {
        "flagAnti": flagAnti,
        "initQ" : initQ,
    },);
    return b;
  }

  static Future<bool> get stopInventory async {
    final bool b = await _channel.invokeMethod('stopInventory');
    return b;
  }

  static Future<String> convertUiiToEPC ({ String uii }) async {
    return await _channel.invokeMethod('convertUiiToEPC', {'uii': uii});
  }
}

class SimpleRFIDEntity {

}
